Do not steal primary selection on mark deactivation.
authorChong Yidong <cyd@gnu.org>
Sun, 8 Jul 2012 06:09:21 +0000 (14:09 +0800)
committerChong Yidong <cyd@gnu.org>
Sun, 8 Jul 2012 06:09:21 +0000 (14:09 +0800)
* lisp/simple.el (deactivate-mark): Do not set the primary selection
if another program has acquired it.

lisp/ChangeLog
lisp/simple.el

index 504f237e2ff2dfe7a7dad7311f0e14eda5d440f8..79d6555b60cc0fa6d60eac2efbac3390b27cef58 100644 (file)
@@ -1,3 +1,8 @@
+2012-07-08  Chong Yidong  <cyd@gnu.org>
+
+       * simple.el (deactivate-mark): Do not set the primary selection
+       if another program has acquired it (Bug#11772).
+
 2012-07-07  Kevin Ryde  <user42@zip.com.au>
 
        * woman.el (woman-strings): Fix double-quote handling (Bug#1151).
index 4527a9da0dc2de382b1991b933b031067a78def4..e6b4a79b9b2563c6a5f935acddabe801177b3509 100644 (file)
@@ -3863,7 +3863,11 @@ run `deactivate-mark-hook'."
       (cond (saved-region-selection
             (x-set-selection 'PRIMARY saved-region-selection)
             (setq saved-region-selection nil))
-           ((/= (region-beginning) (region-end))
+           ;; If another program has acquired the selection, region
+           ;; deactivation should not clobber it (Bug#11772).
+           ((and (/= (region-beginning) (region-end))
+                 (or (x-selection-owner-p 'PRIMARY)
+                     (null (x-selection-exists-p 'PRIMARY))))
             (x-set-selection 'PRIMARY
                              (buffer-substring-no-properties
                               (region-beginning)